package com.bff.gaia.streaming.api.xjoin.client.hbase.all;

import com.bff.gaia.api.java.typeutils.RowTypeInfo;
import com.bff.gaia.streaming.api.xjoin.client.hbase.core.RowKeyBuilder;
import com.bff.gaia.streaming.api.xjoin.client.hbase.core.table.HbaseSideTableInfo;
import com.bff.gaia.streaming.api.xjoin.core.side.FieldInfo;
import com.bff.gaia.streaming.api.xjoin.core.side.JoinInfo;
import com.bff.gaia.streaming.api.xjoin.core.side.SideInfo;
import com.bff.gaia.streaming.api.xjoin.core.side.SideTableInfo;

import java.util.List;

public class HbaseAllSideInfo extends SideInfo {

	private RowKeyBuilder rowKeyBuilder;

	public HbaseAllSideInfo(RowTypeInfo rowTypeInfo, JoinInfo joinInfo, List<FieldInfo> outFieldInfoList, SideTableInfo sideTableInfo) {
		super(rowTypeInfo, joinInfo, outFieldInfoList, sideTableInfo);
	}

	@Override
	public void buildEqualInfo(JoinInfo joinInfo, SideTableInfo sideTableInfo) {

		if (!((HbaseSideTableInfo) sideTableInfo).isQualifierQuery()) {
			rowKeyBuilder = new RowKeyBuilder();
			if (sideTableInfo.getPrimaryKeys().size() < 1) {
				throw new RuntimeException("Primary key dimension table must be filled");
			}
			rowKeyBuilder.init(sideTableInfo.getPrimaryKeys().get(0));
		}


//		String sideTableName = joinInfo.getSideTableName();
//		SqlNode conditionNode = joinInfo.getCondition();
//
//		List<SqlNode> sqlNodeList = Lists.newArrayList();
//		if(conditionNode.getKind() == SqlKind.AND){
//			sqlNodeList.addAll(Lists.newArrayList(((SqlBasicCall)conditionNode).getOperands()));
//		}else{
//			sqlNodeList.add(conditionNode);
//		}
//
//		for(SqlNode sqlNode : sqlNodeList){
//			dealOneEqualCon(sqlNode, sideTableName);
//		}
	}

	public RowKeyBuilder getRowKeyBuilder() {
		return rowKeyBuilder;
	}

	public void setRowKeyBuilder(RowKeyBuilder rowKeyBuilder) {
		this.rowKeyBuilder = rowKeyBuilder;
	}
}